<?php
/**
 * 审批管理——我发起的审批
 * User: zhao shou qiang
 * Date: 2018/1/12 0012
 * Time: 16:44
 */

use yii\widgets\LinkPager;
use yii\helpers\Url;
use yii\helpers\Html;
use frontend\assets\AppAsset;


$this->registerCssFile('@web/css/my-approve.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerCssFile('@web/css/paging.css', ['depends' => ['backend\assets\AppAsset'], 'position' => $this::POS_HEAD]);
$this->registerCss('
    .un-can-click{cursor: default!important;color: #888888!important;}
');

AppAsset::addScript($this, '@web/js/my-approve.js');
AppAsset::addScript($this, '@web/js/myApplication.js');

?>
<style type="text/css">
	.mytable tr:nth-child(even) td span{
		font-size: 14px!important;
		font-weight: 100!important;
	}
	.mytable tr td:nth-child(even) span{
		font-size: 14px!important;
		font-weight: 100!important;
	}
</style>

<!--资产包详情列表结开始-->

<div class="container">
    <div class="row ">
        <div class="top">
            <img src="/image/myAssetBag/wsxx.png" class="pull-left"/>
            <p>我发起的审批</p>
        </div>
        <ul id="myTabTwo" class="nav nav-tabs">
            <li class="<?php if ($ajax['index'] == 0) {
                echo 'active';
            } ?>">
                <a href="#quanBu" data-toggle="tab" onclick="setStatus(0,0,0)">
                    全部（<span><?php echo $counts['allCounts']; ?></span>）
                </a>
            </li>
            <li class="<?php if ($ajax['index'] == 1) {
                echo 'active';
            } ?>">
                <a href="#tongGuo" data-toggle="tab" onclick="setStatus(2,2,1)">
                    已通过（<span><?php echo $counts['passCounts']; ?></span>）
                </a>
            </li>
            <li class="<?php if ($ajax['index'] == 2) {
                echo 'active';
            } ?>">
                <a href="#weiTongGuo" data-toggle="tab" onclick="setStatus(3,2,2)">
                    未通过（<span><?php echo $counts['refuseCounts']; ?></span>）
                </a>
            </li>
            <li class="<?php if ($ajax['index'] == 3) {
                echo 'active';
            } ?>">
                <a href="#shenPiZhong" data-toggle="tab" onclick="setStatus(1,1,3)">
                    审批中（<span><?php echo $counts['unauditedCounts']; ?></span>）
                </a>
            </li>
        </ul>

        <div id="myTabContent" class="tab-content">
            <div class="tab-pane fade in active" id="quanBu">
                <form class="tabForm" action="">
                    <?php
                    $html = '';
                    if (!empty($data) && is_array($data)) {
                        foreach ($data as $key => $value) {
                            if ($value['is_package'] == 1) {
                                $show_title = '资产包名称';
                            } else {
                                $show_title = '项目名称';
                            }
                            $html .= '<table border="" cellspacing="" cellpadding="" class="mytable">
                                    <tr>
                                        <td colspan="8">' . $value['type'] . '</td>
                                    </tr>
                                    <tr>
                                        <td style="width: 100px;">' . $show_title . ':</td>
                                        <td>';

                            if($value['is_package'] == 1) {
                                $filterPackage = \backend\controllers\DtActionFilter::checkPackage("package_view", $value['package_id']);
                                if ($filterPackage){
                                    $pacUrl = Url::toRoute(['package/detail-info', 'packageid' => $value['package_id']]);
                                    $a = '<a href="javascript:void(0);" onclick="javascript:window.open(' . "'" . $pacUrl . "'" . ')">';
                                }else{
                                    $a = '<a href="javascript:layer.msg(\'您没有访问权限\')">';
                                }
                                $html .= $a . '<span class="txt-cut" title="" style="color:#2096f1;cursor:pointer;">' . $value['application_tilte'] . '</span></a>';
                            } elseif($value['is_package'] == 2) {
                                $packageModel = \common\models\Project::findOne((int)$value['package_id']);
                                $filterProject = \backend\controllers\DtActionFilter::checkProject("project_view",$value['package_id']);
                                if ($filterProject){
                                    $proUrl = Url::toRoute(['project/getinfodata', 'package_id' => $packageModel['package_id'], 'project_id'=>$value['package_id']]);
                                    $a = '<a href="javascript:void(0);" onclick="javascript:window.open(' . "'" . $proUrl . "'" . ')">';
                                }else{
                                    $a = '<a href="javascript:layer.msg(\'您没有访问权限\')">';
                                }
                                $html .= $a . '<span class="txt-cut" title="" style="color:#2096f1;cursor:pointer;">' . $value['application_tilte'] . '</span></a>';
                            }

                            $html .='</td>
                                        <td>
                                            申请时间:
                                        </td>
                                        <td>
                                            <span>' . $value['applied_at'] . '</span>
                                        </td>
                                        <td>
                                            审批结果:
                                        </td>
                                        <td>
                                            <span>' . $value['result'] . '</span>
                                        </td>
                                        <td>
                                            审批人:
                                        </td>
                                        <td>
                                            <span title="' . $value['user'] . '">' . $value['user'] . '</span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>申请理由:</td>
                                        <td colspan="3">
                                            <div style="word-break: break-all; word-wrap: break-word; width: 400px;">
                                                ' . $value['reason'] . '
                                            </div>
                                        </td>     
                                        <td>审批意见:</td>
                                        <td colspan="3">
                                            <div style="word-break: break-all; word-wrap: break-word; width: 400px;">
                                                ' . $value['note'] . '
                                            </div>
                                        </td> 
                                    </tr>
                                    <tr>
                                        <td>
        
                                        </td>
                                    </tr>
                                </table>';
                        }
                    }
                    echo $html;
                    ?>
                </form>
            </div>
        </div>
    </div>

    <div class="pagingBox">
        <div id="page_list" class="pull-left" style="padding-left: 0px!important;">
            <?php echo $pages; ?>
        </div>
       <!--<div class="pull-left">
                    <span class="pageTotal pull-left">
                        <span class="pageT"></span> 每页
                        <a id="list">
                            <span class="number"><?php echo $ajax['pageSize']; ?></span>
                            <ul class="pageTotalBox">
                                <li class="<?php if ($ajax['page'] == 10) {
                                    echo 'pageActive';
                                } ?>">10</li>
                                <li class="<?php if ($ajax['page'] == 20) {
                                    echo 'pageActive';
                                } ?>">20</li>
                                <li class="<?php if ($ajax['page'] == 30) {
                                    echo 'pageActive';
                                } ?>">30</li>
                                <li class="<?php if ($ajax['page'] == 40) {
                                    echo 'pageActive';
                                } ?>">40</li>
                                <li class="<?php if ($ajax['page'] == 50) {
                                    echo 'pageActive';
                                } ?>">50</li>
                            </ul>
                        </a>
                        <b class="caret"> </b>行
                    </span>
            共<span class="totalSize"><?php echo $count; ?> </span>条记录
        </div>-->
    </div>
</div>


<script type="text/javascript">
	$(function(){
		//单击tabel 进行高亮显示
		$(document).on('click','.mytable',function(){
			$(this).addClass('border').siblings().removeClass('border')
		})
	})
</script>
